package ecom.beans;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.EntityContext;
import javax.ejb.FinderException;
import javax.ejb.ObjectNotFoundException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;
import javax.persistence.Column;

@Entity
@Table(name="Product")
public class ProductBean implements java.io.Serializable{
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)	
    @Column(name="id")
    private int          id;
    
    @Column(name="name")
    private String       name;

    @Column(name="price")
    private double       price;
    
    @ManyToOne
    @JoinColumn(name = "ProductStoreId")
    private int          productStore;
    
    @Column(name="location")
    private String       location;
    
    
    public ProductBean(){
    }

    public ProductBean(int id,String name,double price,int productStore,String location){
	this.setId(id);
	this.setName(name);
	this.setPrice(price);
	this.setProductStore(productStore);
	this.setLocation(location);
    }
    public ProductBean(ProductBean p){
	setId(p.getId());
	setName(p.getName());
	setPrice(p.getPrice());
	setProductStore(p.getProductStore());
	setLocation(p.getLocation());
    }
    
    @Override
    public String toString(){
	return "["+getId()+","+getName()+"-"+getPrice()+"- vendu chez :"+getProductStore()+"]";
    }
    
    public int getId(){
	return this.id;
    }
    public void setId(int id){
	this.id = id;
    }
    
    public String getName(){
	return this.name;
    }
    public void setName(String name){
	this.name=name;
    }
    public double getPrice(){
	return this.price;
    }
    public void setPrice(double price){
	this.price = price;
    }
    public int getProductStore(){
	return this.productStore;
    }
    public void setProductStore(int store){
	this.productStore = store;
    }
    
    public void setLocation(String location){
	this.location = location;
    }
    public String getLocation(){
	return this.location;
    }
}
    

